/**********************************************************************************************************************
 *
 * Project:    mGameEngine
 * File:       spotlight.h
 * Author:     karooolek
 * Created on: 2009-03-27
 *
 **********************************************************************************************************************/

#ifndef SPOTLIGHT_H_
#define SPOTLIGHT_H_

#include "positionallight.h"

namespace mGameEngine
{
namespace Graphics
{

/**
 * Oriented spotlight.
 * It has specified light cone.
 */
class SpotLight : public PositionalLight
{
protected:
    /**
     * Direction.
     */
    Vector3 _direction;

    /**
     * Inner cone angle.
     */
    float _innerCone;

    /**
     * Outer cone angle.
     */
    float _outerCone;

public:
    /**
     * Create new spotlight.
     */
    SpotLight();

    /**
     * Create new spotlight with specified colors, cones angles,
     * attenuation factors, position and direction.
     * @param ambient ambient light color
     * @param diffuse diffuse light color
     * @param specular specular light color
     * @param constantAttenuation constant attenuation factor
     * @param linearAttenuation linear attenuation factor
     * @param quadraticAttenuation quadratic attenuation factor
     * @param innerCone inner cone angle in radians
     * @param outerCone outer cone angle in radians
     * @param position position.
     * @param direction direction.
     */
    SpotLight(const Color &ambient, const Color &diffuse, const Color &specular,
              float constantAttenuation = 1.0f, float linearAttenuation = 0.0f,
              float quadraticAttenuation = 0.0f,
              float innerCone = M_PI_4, float outerCone = M_PI_2,
              const Vector3 &position = Vector3(),
              const Vector3 &direction = Vector3(1.0f, 0.0f, 0.0f));

    /**
     * Get spotlight direction.
     * @return spotlight direction.
     */
    const Vector3 &getDirection() const
    {
        return _direction;
    }

    /**
     * Set spotlight direction.
     * @param direction direction.
     */
    void setDirection(const Vector3 &direction)
    {
        _direction = direction;
    }

    /**
     * Destroy spotlight.
     * @return
     */
    virtual ~SpotLight();

    /**
     * Get inner spotlight cone angle.
     * @return inner cone angle in radians
     */
    float getInnerConeAngle() const
    {
        return _innerCone;
    }

    /**
     * Set inner spotlight cone angle.
     * @param innerCone inner cone angle in radians
     */
    void setInnerConeAngle(float innerCone)
    {
        _innerCone = innerCone;
    }

    /**
     * Get outer spotlight cone angle.
     * @return outer cone angle in radians
     */
    float getOuterConeAngle() const
    {
        return _outerCone;
    }

    /**
     * Set outer spotlight cone angle.
     * @param outerCone outer cone angle in radians
     */
    void setOuterConeAngle(float outerCone)
    {
        _outerCone = outerCone;
    }

    /**
     * Set spotlight on graphics scene.
     * @param l light identifier
     */
    virtual void set(uint l) const;
};

}
}

#endif // SPOTLIGHT_H_
